package com.atguigu.day07;

public class Test08 {
    public static void main(String[] args) {
        DateCommonsTools d1 = new DateCommonsTools();
        System.out.println(d1.getWeekName(6));
        System.out.println(d1.getMonthName(6) + "\n**********************");
        System.out.println(d1.getTotalDaysOfMonth(2021, 4) + "\n**********************");
        System.out.println(d1.getTotalDaysOfYear(2021));
        System.out.println(d1.isLeapYear(2021));
    }

}

class DateCommonsTools {
    String getWeekName(int week) {
        switch (week) {
            case 7:
                return "sunday";
            case 1:
                return "monday";
            case 2:
                return "tuesday";
            case 3:
                return "wednesday";
            case 4:
                return "thursday";
            case 5:
                return "friday";
            case 6:
                return "saturday";
        }
        return "";
    }

    String getMonthName(int month) {
        switch (month) {
            case 1:
                return "Jar.";
            case 2:
                return "Feb.";
            case 3:
                return "Mar.";
            case 4:
                return "Apr.";
            case 5:
                return "May.";
            case 6:
                return "Jun.";
            case 7:
                return "Jul.";
            case 8:
                return "Aug.";
            case 9:
                return "Sept.";
            case 10:
                return "Oct.";
            case 11:
                return "Nov.";
            case 12:
                return "Dec.";
        }
        return "";
    }

    int getTotalDaysOfMonth(int year, int month) {

        if (month == 1 || month == 3 || month == 5 || month == 7 || month == 8 || month == 10 || month == 12)
            return 31;
        else if (month == 2) {
            if (isLeapYear(year))
                return 29;
            else
                return 28;
        } else
            return 30;

    }

    int getTotalDaysOfYear(int year) {
        if (isLeapYear(year))
            return 366;
        else
            return 365;
    }

    boolean isLeapYear(int year) {
        if (year % 4 == 0 && year % 100 != 0 || year % 400 == 0) {
            System.out.println("当前日期是闰年");
            return true;
        } else {
            System.out.println("当前日期不是闰年");
            return false;
        }
    }
}
